﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using log4net.Appender;
using log4net.Core;
using Microsoft.WindowsAzure.Diagnostics;
using System.Diagnostics;


namespace ThreeByte.ActiveDeck.Web.Logging
{
    public class AzureAppender : AppenderSkeleton
    {
        private static readonly Dictionary<int, string> AzureLevelMapping = new Dictionary<int, string>();
        public AzureAppender() {
            AzureLevelMapping[30000] = "Verbose";
            AzureLevelMapping[40000] = "Information";
            AzureLevelMapping[60000] = "Warning";
            AzureLevelMapping[70000] = "Error";
            AzureLevelMapping[110000] = "Critical";
        }

        protected override void Append(LoggingEvent loggingEvent) {
            Trace.WriteLine(loggingEvent.RenderedMessage, AzureLevelMapping[loggingEvent.Level.Value]);
        }

    }
}
